//package com.nelson.musicplayer.test
//
//import android.graphics.Color
//import android.os.Bundle
//import android.view.View
//import android.widget.Toast
//import androidx.appcompat.app.AppCompatActivity
//import androidx.recyclerview.widget.RecyclerView
//import com.alibaba.android.vlayout.DelegateAdapter
//import com.alibaba.android.vlayout.VirtualLayoutManager
//import com.alibaba.android.vlayout.layout.GridLayoutHelper
//import com.alibaba.android.vlayout.layout.LinearLayoutHelper
//import com.chad.library.adapter.base.BaseViewHolder
//import com.nelson.musicplayer.R
//import com.nelson.musicplayer.helper.GlideImageLoader
//import com.sunfusheng.marqueeview.MarqueeView
//import com.youth.banner.Banner
//import com.youth.banner.BannerConfig
//import com.youth.banner.Transformer
//
//
//class TaobaoActivity : AppCompatActivity() {
//    //不同item必须不同的viewtype
//    var BANNER_VIEW_TYPE = 1
//    var MENU_VIEW_TYPE = 2
//    var NEWS_VIEW_TYPE = 3
//    var TITLE_VIEW_TYPE = 4
//    var GRID_VIEW_TYPE = 5
//
//    //广告位
//    var ITEM_URL =
//        intArrayOf(R.drawable.item1, R.drawable.item2, R.drawable.item3, R.drawable.item4, R.drawable.item5)
//
//    //    应用位
//    var ITEM_NAMES =
//        arrayOf("天猫", "聚划算", "天猫国际", "外卖", "天猫超市", "充值中心", "飞猪旅行", "领金币", "拍卖", "分类")
//    var IMG_URLS = intArrayOf(
//        R.drawable.ic_tian_mao,
//        R.drawable.ic_ju_hua_suan,
//        R.drawable.ic_tian_mao_guoji,
//        R.drawable.ic_waimai,
//        R.drawable.ic_chaoshi,
//        R.drawable.ic_voucher_center,
//        R.drawable.ic_travel,
//        R.drawable.ic_tao_gold,
//        R.drawable.ic_auction,
//        R.drawable.ic_classify
//    )
//
//    //    高颜值商品位
//    var GRID_URL =
//        intArrayOf(R.drawable.flashsale1, R.drawable.flashsale2, R.drawable.flashsale3, R.drawable.flashsale4)
//    private var mAdapters = mutableListOf<DelegateAdapter.Adapter<out BaseViewHolder>>()
//    private lateinit var mRecyclerView: RecyclerView;
//    override fun onCreate(savedInstanceState: Bundle?) {
//        super.onCreate(savedInstanceState)
//        setContentView(R.layout.activity_taobao)
//        mRecyclerView = findViewById(R.id.recycle_view)
//        initView()
//    }
//
//    private fun initView() {
//        var layoutManager = VirtualLayoutManager(this)
//        mRecyclerView.layoutManager = layoutManager
//        var viewPool = RecyclerView.RecycledViewPool()
//        mRecyclerView.setRecycledViewPool(viewPool)
//        viewPool.setMaxRecycledViews(0, 10)
//        var delegateAdapter = DelegateAdapter(layoutManager, true)
//        mRecyclerView.adapter = delegateAdapter
//
//
//        addShufflingFigure(delegateAdapter)
//        addGride(delegateAdapter)
//        addNews(delegateAdapter)
//    }
//
//    private fun addNews(delegateAdapter: DelegateAdapter) {
//        val newsAdapter: BaseDelegateAdapter = object : BaseDelegateAdapter(
//            LinearLayoutHelper()
//            , 1, R.layout.vlayout_news, NEWS_VIEW_TYPE
//        ) {
//            override fun onBindViewHolder(holder: BaseViewHolder, position: Int) {
//                val marqueeView1 = holder.getView<MarqueeView>(R.id.marqueeView1)
//                val marqueeView2 = holder.getView<MarqueeView>(R.id.marqueeView2)
//                val info1: MutableList<String> = ArrayList()
//                info1.add("天猫超市最近发大活动啦，快来抢")
//                info1.add("没有最便宜，只有更便宜！")
//                val info2: MutableList<String> = ArrayList()
//                info2.add("这个是用来搞笑的，不要在意这写小细节！")
//                info2.add("啦啦啦啦，我就是来搞笑的！")
//                marqueeView1.startWithList(info1)
//                marqueeView2.startWithList(info2)
//                // 在代码里设置自己的动画
//                marqueeView1.startWithList(info1, R.anim.anim_bottom_in, R.anim.anim_top_out)
//                marqueeView2.startWithList(info2, R.anim.anim_bottom_in, R.anim.anim_top_out)
//                marqueeView1.setOnItemClickListener { position, textView ->
//                    Toast.makeText(applicationContext, textView.text.toString(), Toast.LENGTH_SHORT)
//                        .show()
//                }
//                marqueeView2.setOnItemClickListener { position, textView ->
//                    Toast.makeText(applicationContext, textView.text.toString(), Toast.LENGTH_SHORT)
//                        .show()
//                }
//            }
//        }
//        delegateAdapter.addAdapter(newsAdapter)
//    }
//
//    private fun addGride(delegateAdapter: DelegateAdapter) {
//        //menu
//        // 在构造函数设置每行的网格个数
//
//        //menu
//        // 在构造函数设置每行的网格个数
//        val gridLayoutHelper = GridLayoutHelper(5)
//        gridLayoutHelper.setPadding(0, 16, 0, 16)
//        gridLayoutHelper.vGap = 16 // 控制子元素之间的垂直间距
//
//        gridLayoutHelper.hGap = 0 // 控制子元素之间的水平间距
//
//        gridLayoutHelper.bgColor = Color.WHITE
//
//        val menuAdapter: BaseDelegateAdapter = object : BaseDelegateAdapter(
//            gridLayoutHelper, 10
//            , R.layout.vlayout_menu, MENU_VIEW_TYPE
//        ) {
//            override fun onBindViewHolder(holder: BaseViewHolder, position: Int) {
//                holder.setText(R.id.tv_menu_title_home, ITEM_NAMES[position] + "")
//                holder.setImageResource(R.id.iv_menu_home, IMG_URLS[position])
//                holder.getView<View>(R.id.ll_menu_home).setOnClickListener {
//                    Toast.makeText(applicationContext, ITEM_NAMES[position], Toast.LENGTH_SHORT).show()
//                }
//            }
//        }
//        delegateAdapter.addAdapter(menuAdapter)
//    }
//
//    private fun addShufflingFigure(delegateAdapter: DelegateAdapter) {
//        var adapter =
//            object : BaseDelegateAdapter(LinearLayoutHelper(), 1, R.layout.vlayout_banner, BANNER_VIEW_TYPE) {
//                override fun onBindViewHolder(holder: BaseViewHolder, position: Int) {
//                    val arrayList: ArrayList<String?> = ArrayList()
//                    arrayList.add("https://img.alicdn.com/tfs/TB1l6mOMBr0gK0jSZFnXXbRRXXa-520-280.jpg_q90_.webp")
//                    arrayList.add("https://img.alicdn.com/simba/img/TB1h.u.GYj1gK0jSZFOSuw7GpXa.jpg")
//                    val mBanner: Banner = holder.getView(R.id.banner)
//                    mBanner.setBannerStyle(BannerConfig.CIRCLE_INDICATOR)
//                    mBanner.setImageLoader(GlideImageLoader())
//                    mBanner.setImages(arrayList)
//                    mBanner.setBannerAnimation(Transformer.DepthPage)
//                    mBanner.isAutoPlay(true)
//                    mBanner.setDelayTime(5000)
//                    mBanner.setIndicatorGravity(BannerConfig.CENTER)
//                    mBanner.start()
//                    mBanner.setOnBannerListener { position ->
//                        Toast.makeText(
//                            applicationContext,
//                            "banner点击了$position",
//                            Toast.LENGTH_SHORT
//                        ).show()
//                    }
//                }
//            }
//        delegateAdapter.addAdapter(adapter)
//    }
//}
